package com.wingsofts.gankclient.ui.activity

import android.annotation.SuppressLint
import android.databinding.DataBindingUtil
import android.os.Bundle
import android.webkit.WebView
import android.webkit.WebViewClient
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.wingsofts.gankclient.R
import com.wingsofts.gankclient.databinding.ActivityDetailBinding
import kotlinx.android.synthetic.main.activity_detail.*

@Route(path = "/activity/DetailActivity")
class DetailActivity : BaseBindingActivity<ActivityDetailBinding>() {

    @Autowired(name = "detailUrl")
    lateinit var detailUrl: String

    override fun createDataBinding(savedInstanceState: Bundle?): ActivityDetailBinding {
        return DataBindingUtil.setContentView(this, R.layout.activity_detail)
    }

    @SuppressLint("SetTextI18n")
    override fun initView() {
        ARouter.getInstance().inject(this)
        supportActionBar?.title = "gank.io"
        supportActionBar?.setDisplayHomeAsUpEnabled(true)
        webView.loadUrl(detailUrl)
        webView.webViewClient = object : WebViewClient() {
            override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
                view?.loadUrl(url)
                return true
            }
        }
    }
}
